<template>
  <froala v-model="content"  :config="config"></froala>
</template>
<script>
export default {
  data() {
    return {
      editor: null,
      content:this.$store.state.xiugaiflag != "" ? this.$store.state.content : "",
      config: {
        zIndex: 2501,
        height: "600",
        toolbarSticky: false,
        autofocus: true,
        toolbarButtons: [
          "fullscreen",
          "bold",
          "italic",
          "underline",
          "strikeThrough",
          "subscript",
          "superscript",
          "|",
          "fontFamily",
          "fontSize",
          "color",
          "inlineClass",
          "inlineStyle",
          "paragraphStyle",
          "lineHeight",
          "|",
          "paragraphFormat",
          "align",
          "formatOL",
          "formatUL",
          "outdent",
          "indent",
          "quote",
          "-",
          "insertLink",
          "insertImage",
          "insertVideo",
          "embedly",
          "insertFile",
          "insertTable",
          "|",
          "emoticons",
          "fontAwesome",
          "specialCharacters",
          "insertHR",
          "selectAll",
          "clearFormatting",
          "|",
          "print",
          "getPDF",
          "spellChecker",
          "help",
          "html",
          "|",
          "undo",
          "redo"
        ],
        placeholder: "请填写内容",
        language: "zh_cn",
        imageDefaultWidth: 500,
        imageUploadURL: "",
        videoUploadURL: "http://vip.bearing.cn/uploadFile.php",
        fileUploadURL: "",
        imageManagerLoadURL: "http://vip.bearing.cn/wenzhang/uploadFile.php",
        requestHeaders: { 
          Authorization: localStorage.eleToken,
          Sqdwid:this.$store.state.bbl_sqdwid
        },
        events: {
          "froalaEditor.initialized": (e, editor) => {
            this.editor = editor;
          },
          "froalaEditor.contentChanged": (e, editor) => {
            this.$emit("on-change", editor.html.get(true));
          }
        }
      }
    };
  },
  methods: {
    setHtml(html) {
      if (this.editor) {
        this.editor.html.set(html);
      }
    }
  },
  created() {
    console.log(this.$route.path);
    console.log(this.content)
    // this.content=this.$store.state.content
            console.log('this.$store.state.content',this.$store.state.content)

    var path = this.$route.path;
    if (path == "/tjwz"||path == "/glwz"||path == "/cpfl") {
      this.config.imageUploadURL =
        "https://vip.bearing.cn/uploadFile.php?sqdwid="+sessionStorage.getItem('sqdwid')+'&uploadType=1';
        this.config.fileUploadURL="https://vip.bearing.cn/uploadFile.php?sqdwid="+sessionStorage.getItem('sqdwid')+'&uploadType=1';
        console.log(this.config.imageUploadURL)
    } else if(path=='/qywz'){
            this.config.imageUploadURL =
        "https://vip.bearing.cn/uploadFile.php?sqdwid="+this.$store.state.glxgsqdwid+'&uploadType=1';
        this.config.fileUploadURL="https://vip.bearing.cn/uploadFile.php?sqdwid="+sessionStorage.getItem('sqdwid')+'&uploadType=1';

        console.log(this.config.imageUploadURL)

    }else if(path=='/tjcp'||path=='/cpgl'){
            this.config.imageUploadURL =
        "https://vip.bearing.cn/uploadFile.php?sqdwid="+sessionStorage.getItem('sqdwid')+'&uploadType=2';
        this.config.fileUploadURL="https://vip.bearing.cn/uploadFile.php?sqdwid="+sessionStorage.getItem('sqdwid')+'&uploadType=2';
        console.log(this.config.imageUploadURL)
        this.content=this.$store.state.xiugaiflag != "" ?this.$store.state.cpglxg.remark:""
        // this.$store.state.xiugaiflag != "" ? this.$store.state.content : ""
    } else if(path=='/fbzs'){
        this.config.imageUploadURL =
        "https://vip.bearing.cn/zhishi/uploadFile.php";
        this.config.fileUploadURL="https://vip.bearing.cn/zhishi/uploadFile.php";

        console.log(this.config.imageUploadURL)

    }else if(path=='/fbxw'){
        this.config.imageUploadURL =
        "https://vip.bearing.cn/xinwen/uploadFile.php";
        this.config.fileUploadURL="https://vip.bearing.cn/xinwen/uploadFile.php";

        console.log(this.config.imageUploadURL)

    }
  },
  mounted() {
            console.log('this.$store.state.content',this.$store.state.content)
    
  },
  

};
</script>

<style>
.fr-box.fr-basic .fr-wrapper {
  overflow-y: scroll !important;
  max-height: 300px !important;
}
.fr-box.fr-basic.fr-top .fr-wrapper{
}
.fr-box.fr-basic .fr-element{
      min-height: 250px!important;
}
a[href="https://froala.com/wysiwyg-editor"], a[href="https://www.froala.com/wysiwyg-editor?k=u"],a[href="https://www.froala.com/wysiwyg-editor?pb=1"],p[data-f-id="pbf"] {
  position: absolute;
  top: -99999999px;
  opacity: 0;
}
.fr-placeholder {
  margin-top: 0 !important;
}
@media (min-width: 1600px){
  .fr-box.fr-basic .fr-wrapper {
  max-height: 280px !important;
}
}
</style>